﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.DataAccess;

namespace Hkwl.WorldExpo.Merchant.Service.Impl
{
    public class MerchantServiceImpl : IMerchantService
    {
        private IMerchantDao infoDao;

        public MerchantServiceImpl(IMerchantDao infoDao)
        {
            this.infoDao = infoDao;
        }

        #region NxMerchant 对象

        public NxMerchant GetNxMerchant(int merchantId)
        {
            return infoDao.GetNxMerchant(merchantId);
        }

        public bool InsertNxMerchant(NxMerchant merchant)
        {
            return infoDao.InsertNxMerchant(merchant);
        }

        public bool UpdateNxMerchant(NxMerchant merchant)
        {
            return infoDao.UpdateNxMerchant(merchant);
        }

        public NxMerchant CheckMerchantLogin(string loginName, string password)
        {
            return infoDao.CheckMerchantLogin(loginName, password);
        }

        public IList<NxMerchant> GetNxMerchantCollection(int status, int pageIndex, int pageSize, ref int count)
        {
            return infoDao.GetNxMerchantCollection(status, pageIndex, pageSize, ref count);
        }

        #endregion

        #region NxShopType 对象

        public IList<NxShopType> GetShopTypeCollection()
        {
            return infoDao.GetShopTypeCollection();
        }

        public bool InsertNxShopType(NxShopType shopType)
        {
            return infoDao.InsertNxShopType(shopType);
        }

        #endregion

        #region NxMerchantLog 对象

        public bool InsertNxMerchantLog(NxMerchantLog log)
        {
            return infoDao.InsertNxMerchantLog(log);
        }

        public NxMerchantLog GetNxMerchantLogById(NxMerchantLog logId)
        {
            return infoDao.GetNxMerchantLogById(logId);
        }

        public IList<NxMerchantLog> GetNxMerchantLogCollection(int merchantId, int shopTypeId, int pageIndex, int pageSize, ref int count)
        {
            return infoDao.GetNxMerchantLogCollection(merchantId, shopTypeId, pageIndex, pageSize, ref count);
        }

        #endregion

        /// <summary>
        /// 通用记录商家操作日志
        /// </summary>
        /// <param name="strFormat">输入字符串格式</param>
        /// eg:查看商家信息{0}
        /// <param name="ViewLog">传入的变量</param>
        public void CommonInsertFormatLog(int merchantId, int shopTypeId, string strFormat)
        {
            NxMerchantLog merchantLog = new NxMerchantLog();

            merchantLog.MerchantId = merchantId;
            merchantLog.ShopTypeId = shopTypeId;
            merchantLog.LogContent = strFormat;
            merchantLog.LogTime = DateTime.Now;

            ServiceLocator.IMerchantService.InsertNxMerchantLog(merchantLog);
        }
    }
}
